﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BL.Entities;
//using AcroPDFLib;
//using AxAcroPDFLib;
//using AxPdfLib;
//using PdfLib;
//using PdfSharp;
//using PdfSharp.Viewing;
using System.Diagnostics;
using BL.DataAccess;

//using CalendarDemo;



namespace zCO
{
    public partial class frmMain : Form
    {
        System.Diagnostics.Process proc;
        public frmMain()
        {
            InitializeComponent();
        }

        private  void Form1_Load(object sender, EventArgs e)
        {
            if (!System.IO.File.Exists(Configuration.Current.DataBasePath ))
            {

                MessageBox.Show("No se pudo acceder a la base de datos, la aplicacion se cerrara (" + Configuration.Current.DataBasePath+")");

                Application.Exit();

            }

            if (!Configuration.Current.DataBasePath.StartsWith("\\"))
            {
                BackUpDB.Create();
            }
        
        }

        private void agegarProfesionalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmABMProfesional frmP = new frmABMProfesional();
            frmP.Show();
        }

        private void listarPrestacionesToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void editarEliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //ESTO NO VA ACA
            frmEditPrestacion frm = new frmEditPrestacion();
            frm.Show();
        }

        private void obrasSocialesToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = comboBox1.SelectedIndex;
            switch (index)
            {
                case 0: frmABMProfesional formABM = new frmABMProfesional();
                    formABM.Show();
                    break;
                case 1: frmEditProf formEdit = new frmEditProf();
                    formEdit.Show();
                    break;
                case 2: frmABMMovimiento formMov = new frmABMMovimiento();
                    formMov.Show();
                    break;
                case 3: frmListarMovimentos formBusc = new frmListarMovimentos();
                    formBusc.Show();
                    break;
                case 4: frmListarLiquidaciones formLiq = new frmListarLiquidaciones();
                    formLiq.Show();
                    break;




            }
        }

        private void agregarToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            frmABMPaciente frm = new frmABMPaciente();
            frm.Show();
        }

        private void editarProfesionalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmEditProf formEdit = new frmEditProf();
            formEdit.Show();
        }

        private void modificarEliminarToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frmEditPaciente frm = new frmEditPaciente();
            frm.Show();
        }

        private void modificarEliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmEditObraSocial frm = new frmEditObraSocial();
            frm.Show();
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
            //  DemoForm turnos = new DemoForm();
            // turnos.Show();

            proc = new System.Diagnostics.Process();
            proc.EnableRaisingEvents = false;
            proc.StartInfo.FileName = "CalendarDemo.exe";
            proc.StartInfo.Arguments = "";
            proc.Start();

        }

        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = comboBox5.SelectedIndex;
            switch (index)
            {
                case 0:
                    frmAgregarDetallePrestacion frm = new frmAgregarDetallePrestacion();
                    frm.Show();
                    break;
                case 1: frmListaPrestaciones formListPrest = new frmListaPrestaciones();
                    formListPrest.Show();
                    break;

            }

        }

        private void listaToolStripMenuItem_Click(object sender, EventArgs e)
        {

            frmAgregarDetallePrestacion frm = new frmAgregarDetallePrestacion();
            frm.Show();
        }

        private void cuotasDeClientesToolStripMenuItem_Click(object sender, EventArgs e)
        {


        }

        private void ayudaToolStripMenuItem_Click(object sender, EventArgs e)
        {


        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {

            try
            {
                proc.CloseMainWindow();
            }
            catch (Exception ex)
            {


            }

        }

        private void agregarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmABMPrestaciones frm = new frmABMPrestaciones();
            frm.Show();
        }

        private void agregarMovimientoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmABMMovimiento frm = new frmABMMovimiento();
            frm.Show();
        }

        private void consultarMovimientosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmListarMovimentos frm = new frmListarMovimentos();
            frm.Show();

        }

        private void agregarToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frmABMObraSocial frm = new frmABMObraSocial();
            frm.Show();
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = comboBox2.SelectedIndex;
            switch (index)
            {
                case 0:
                    frmABMPrestaciones frm = new frmABMPrestaciones();
                    frm.Show();
                    break;
                case 1: frmEditPrestacion frm2 = new frmEditPrestacion();
                    frm2.Show();
                    break;
            }

        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = comboBox3.SelectedIndex;
            switch (index)
            {
                case 0:
                    frmABMObraSocial frm = new frmABMObraSocial();
                    frm.Show();
                    break;
                case 1: frmEditObraSocial frm2 = new frmEditObraSocial();
                    frm2.Show();
                    break;
            }
        }

        private void comboBox4_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            int index = comboBox4.SelectedIndex;
            switch (index)
            {
                case 0:
                    frmABMPaciente frm = new frmABMPaciente();
                    frm.Show();
                    break;
                case 1: frmEditPaciente frm2 = new frmEditPaciente();
                    frm2.Show();
                    break;
            }
        }

        private void listarIntervenciónToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmListaPrestaciones frm = new frmListaPrestaciones();
            frm.Show();
        }

        private void formularioDePrestacionesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmListaPrestaciones frm = new frmListaPrestaciones();
            frm.Show();
        }

        private void compranteCuotasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmListarMovimentos frm = new frmListarMovimentos();
            frm.Show();

        }

        private void acercaDeCirculoOdontologicoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAcercaDe frm = new frmAcercaDe();
            frm.Show();
        }

        private void salirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void generarCuotaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Cuota.ChequearCuota() == true)
            {
                DialogResult dr = MessageBox.Show("¿Desea generar las cuotas de todos los profesionales del mes de " + DateTime.Now.ToString("MMMM") + " ?", "Generar Coutas", MessageBoxButtons.YesNoCancel);
                switch (dr)
                {
                    case DialogResult.Abort:
                        break;
                    case DialogResult.Cancel:
                        break;
                    case DialogResult.Ignore:
                        break;
                    case DialogResult.No:
                        break;
                    case DialogResult.None:
                        break;
                    case DialogResult.OK:
                        break;
                    case DialogResult.Retry:
                        break;
                    case DialogResult.Yes:
                        Cuota.GenerarCoutas();
                        MessageBox.Show("Las Coutas se generaron correctamente");
                        break;
                    default:
                        break;
                }
            }
            else
            {

                MessageBox.Show("Ya se generaron las cuotas para el mes vigente");
            }
        }

        private void liquidarIntervencionesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmListarLiquidaciones frm = new frmListarLiquidaciones();
            frm.Show();
        }


        private void configuracionesToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frmConfiguracion frm = new frmConfiguracion();
            frm.Show();
        }

        private void documentoDeAyudaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Process.Start("HelpFile.pdf");
            //PdfViewer frm= new PdfViewer();
            //frm.Show();
            
        }
    }
}

